<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css" media="all">
    <style>body{padding:10px;font-size:14px;background:#fff;width:95%;margin:0 auto;font-size:14px;line-height:20px;overflow:hidden;}p{margin-bottom:10px;}input{border:1px solid #999;padding:5px 10px;margin:0 10px 10px 0;}</style>
    <style>
        select {
            border-color: #ccc;
            color: #404040;
            padding: 2px;
            height: 27px;
            line-height: 27px;
            border: 1px solid #ccc;
            border-radius: 3px;
            font-family: inherit;
            font-size: 100%;
            outline: 0;
        }
        }
    </style>
</head>
<body>
<div>
    <strong><label>请选择派送人员：</label></strong>
    <div class="layui-inline">
        <select name="" id="worker">
            @if(count($workers))
                @foreach($workers as $v)
                    <option value="{{$v['id']}}" @if($_GET['worker_id'] == $v['id']) selected @endif> {{$v['name']}}({{$v['code']}}) </option>
                @endforeach
            @endif
        </select>
        <button class="layui-btn" id="closeIframe" url="">确定</button>
    </div>
</div>
<script src="//cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
<script src="//res.layui.com/lay/lib/laycode/laycode.min.js"></script>
<script>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    $('#closeIframe').click(function(){
        var worker_id = $('#worker').val();
        if(worker_id === ''){
            parent.layer.msg('请选择派送人员');
            return;
        }
        var url = "{!! urlPlat('single','getBindWorker',['id'=>request('id')]) !!}&type=1&worker_id="+worker_id;
        $.get(url).success(function(data){
            parent.layer.msg(data.info);
            if (data.status==1) {
                parent.location.reload();
                parent.layer.close(index);
            }
        });


    });
</script>
</body>
</html>
